/*
神经网络连接头文件
定义神经元之间的连接权重管理
支持权重初始化和梯度计算
*/
#ifndef CONNECTION_H
#define CONNECTION_H

#include <memory>

class Neuron;

class Connection {
public:
    Connection(int upstreamNeuronId, int downstreamNeuronId);
    ~Connection();
    const int getUpstreamNeuronId() const;
    const int getDownstreamNeuronId() const;
    const std::shared_ptr<Neuron> getUpstreamNeuron() const;
    const std::shared_ptr<Neuron> getDownstreamNeuron() const;
    double getWeight() const;
    void setWeight(double weight);
    void updateWeight(double deltaWeight);
    void calculateGradient();
    double getGradient() const;
    void setGradient(double gradient);
    void print() const;

private:
    int upstreamNeuronId;
    int downstreamNeuronId;
    double weight;
    double gradient;

    void setUpstreamNeuronConnection(int upstreamNeuronId);
    void setDownstreamNeuronConnection(int downstreamNeuronId);
};

#endif // CONNECTION_H